//
//  ExifItem.m

#import "ExifItem.h"


@implementation ExifItem


//------------------------------------------------------------------------------
- (id) initExif:(int)etype  tag:(int)etag name:(NSString*)ename  value:(NSString*)evalue
{
	self = [super init];
	if (nil != self)
	{
		type = etype;
		tag = etag;

		name = ename;
		[name retain];

		value = evalue;
		[value retain];
	}

	return self;
}

//------------------------------------------------------------------------------
- (int) type
{
	return type;
}

//------------------------------------------------------------------------------
- (int) tag
{
	return tag;
}

//------------------------------------------------------------------------------
- (NSString*) name
{
	return name;
}

//------------------------------------------------------------------------------
- (NSString*) value
{
	return value;
}

//------------------------------------------------------------------------------
- (NSComparisonResult) compareExifType:(ExifItem*) ei
{
	if (type < [ei type])
	{
		return NSOrderedAscending;
	}
	else
	if (type > [ei type])
	{
		return NSOrderedDescending;
	}
	else
	{
		return [self compareExifName: ei];
	}
}

//------------------------------------------------------------------------------
- (NSComparisonResult) compareExifName:(ExifItem*) ei
{
	return [name caseInsensitiveCompare: [ei name]];
}

//------------------------------------------------------------------------------
- (NSComparisonResult) compareExifValue:(ExifItem*) ei
{
	return [value caseInsensitiveCompare: [ei value]];
}

//------------------------------------------------------------------------------
- (NSComparisonResult) compareExifTag:(ExifItem*) ei
{
	if (tag < [ei tag])
	{
		return NSOrderedAscending;
	}
	else
	if (tag > [ei tag])
	{
		return NSOrderedDescending;
	}
	else
	{
		return [self compareExifName: ei];
	}
}

//------------------------------------------------------------------------------
- (void) dealloc
{
	[name release];
	[value release];
	[super dealloc];
}

@end
